package com.jt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.UserMapper;
import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/11/17
 */
@Service
public class UserServiceImpl implements UserService {
    private static Map paramMap;
    static {
        paramMap=new HashMap();
        paramMap.put(1,"username");
        paramMap.put(2,"phone");
        paramMap.put(3,"email");
    }

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.selectList(null);
    }

    @Override
    public boolean checkUser(String param, Integer type) {

        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(paramMap.get(type), param);
        return userMapper.selectList(queryWrapper).size()>0;
    }
}
